package com.job.action;

import com.job.dao.CityDao;
import com.job.dao.ProfessionDao;
import com.job.dao.ResumeDao;
import com.job.model.City;
import com.job.model.Profession;
import com.job.model.User;
import com.job.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class Index {
    /**
     * 主页服务层
     */
    private IndexService indexService;

    @RequestMapping("/showIndex.do")
    public String showIndex(Model model, HttpSession session){
        User user= (User) session.getAttribute("user");
        if (user!=null){
            model.addAttribute(user);
        }
        List<Profession> firstPr= professionDao.getAllProfession(1);
        List<Profession> secondPr=professionDao.getAllProfession(2);
        List<Profession> thirdPr=professionDao.getAllProfession(3);
        model.addAttribute("firstPr",firstPr);
        model.addAttribute("sencondPr",secondPr);
        model.addAttribute("thirdPr",thirdPr);

        return "index";
    }










    @Autowired
    public void setIndexService(IndexService indexService) {
        this.indexService = indexService;
    }

    private ResumeDao resumeDao;
    private CityDao cityDao;
    private ProfessionDao professionDao;









    @Autowired
    public void setResumeDao(ResumeDao resumeDao) {
        this.resumeDao = resumeDao;
    }
    @Autowired
    public void setCityDao(CityDao cityDao) {
        this.cityDao = cityDao;
    }
    @Autowired
    public void setProfessionDao(ProfessionDao professionDao) {
        this.professionDao = professionDao;
    }
}
